<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.8/dist/vue.js" type="text/javascript"></script>
</head>
<body>
    <div id="box">
        <h2>人员信息</h2>
        <input type="text" placeholder="请输入关键字" v-model="keyWords">
        <ul>
            <li v-for="(person,index) in filpersons" :key="index">
                {{person.name}}-{{person.age}}-{{person.sex}}
            </li>
        </ul>
    </div>

    <script>
        Vue.config.productionTip = false;  //阻止vue在启动时生成生产提示
        //创建实例
       let vm = new Vue({
            el:"#box",
            data:{
                keyWords:"",
                persons:[
                    {name:'马冬梅',age:19,sex:'女'},
                    {name:'周冬雨',age:19,sex:'女'},
                    {name:'周杰伦',age:20,sex:'男'},
                    {name:'炎亚伦',age:21,sex:'男'}
                ]
            },
            computed:{
                filpersons:{
                    get(){
                        return this.persons.filter((p)=>{
                            return p.name.indexOf(this.keyWords)!== -1
                        })
                    },
                    // set(value){
                    //     console.log(value);
                    // }
                }
            }
            
        })
    </script>
</body>
</html>